<?php

$javascript->link(
			array('http://www.google.com/jsapi'),
			false
		);

		$javascript->codeBlock('var initJquery = function(){google.load("jquery", "1.2");	google.load("jqueryui", "1.5");} ; try {initJquery(); } catch (e){ setTimeout("1000" , initJquery ); }' , array('inline'=>false) );
		
		$javascript->link(
			array(
			'jquery-cycle.js',
			'jquery-easing.js',
			'historyTabs.js'
			),false);

		$html->css(array(
			'views/themes/default/css/jquery-ui/theme/ui.all.css',
			'historyStyles.css'
		)
			,
		'stylesheet', 'media=screen',
		false);

	require('models/hand_analyser.php');
	$handAnalyser = new HandAnalyser();
		$handAnalyser->historyFolder = 'userfiles';
		$handAnalyser->userName = $_SESSION['username'];
		$handAnalyser->handDate = (isset($_REQUEST['date'])) ? $_REQUEST['date'] : date('Ymd');
		$handAnalyser->tableName = (isset($_REQUEST['table'])) ? stripslashes($_REQUEST['table']) : '';

		$handAnalyser->processHandFile();
		
		//echo '<pre>'; print_r($handAnalyser); echo '</pre>';
		?>
    <p><a href="index.php?date=<?php echo $handAnalyser->handDate;?>">Back to Calendar</a></p>
	
	<h1>User: <?php echo $handAnalyser->userName;?></h1>
	<div id="stats">
	<?php $stats = $handAnalyser->tableStats;
	//AF = (Raise % + Bet %) / Call % 
	//print_r($stats['agression']);
	
	
	$afTotal = $stats['agression']['raise']+$stats['agression']['bet']+$stats['agression']['call'];
	$afTotal  = ($afTotal == 0) ? 1: $afTotal;
	$raisePCT = ($stats['agression']['raise']/$afTotal)*100;
	$betPCT = ($stats['agression']['bet']/$afTotal)*100;
	$callPCT = ($stats['agression']['call']/$afTotal)*100;
	
	$callPCT =($callPCT==0) ? 1 : $callPCT;
	
	@$af = ($raisePCT + $betPCT) / $callPCT;
	//echo ($stats['vpp']/$stats['handsSeen']*100);
    				echo( "<div class=\"stats played\">Hands Seen: {$stats['handsSeen']} Played: {$stats['played']} Won: {$stats['won']} Lost: {$stats['lost']} BB: {$stats['bigBlind']} SB: {$stats['smallBlind']} VPP: {$stats['vpp']} (".number_format(($stats['vpp']/$stats['handsSeen'])*100)."%) PFR: {$stats['pfr']} (".number_format($stats['pfr']/$stats['handsSeen']*100)."%) AF: $af WTSD: {$stats['wtsd']}  WTSDW: {$stats['wtsdw']}</div>" );
					
				echo( "<div class=\"stats value\">Total Action: {$stats['totalAction']} Won: {$stats['totalWon']} Lost: {$stats['totalLost']}  BB: {$stats['totalBigBlnd']} SB: {$stats['totalSmallBlnd']} Return: {$stats['roi']} (".number_format($stats['roiPercent'])."%)</div>");
                
                if(isset($stats['sttPosition']) && $stats['sttPosition']!=''){
			echo( '<div>Single Table Tournament Finishing Position = '.$stats['sttPosition'].'</div>' );
				}
				
				?>
</div>
	
	
<div id="dataWrapper">
	<div class="handHistory">
		<?php $handAnalyser->printHandList(); ?>
	</div>

	<div id="informationPane">
    </div>
    <br style="clear:both;"/>
    <?php if($_REQUEST['table']=='STT %238695671.txt'){ ?>
    <div id="comments"><h2><strong>Comments On This Game</strong></h2>
    	<div id="gameComment1234" class="comment">
        	<p>You re-raised he flop with air on the bubble?? Why?</p>
            <div class="comment-author">RonHeywood 02 March 2009 22:28 <a href="#">report</a></div>
        </div>
    </div>
    <?php } ?>
</div>